package inits

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"yzy6.26exam/golbal"
	"yzy6.26exam/internal/moble"
)

func MysqlLink() {
	var err error
	golbal.DB, err = gorm.Open(mysql.Open("root:89B158B4DAFE6F5461878D26EA49B100@tcp(14.103.158.217:3306)/6.26exam?charset=utf8&parseTime=True&loc=Local"))
	if err != nil {
		panic(err)
	}
	if err = golbal.DB.AutoMigrate(&moble.User{}, &moble.Video{}, &moble.Like{}, &moble.Witch{}, &moble.Commit{}); err != nil {
		panic(err)
	}
	fmt.Println("mysql link auto migrate success")
}
